package com.tiankun.eurekasellinfo.service.impl;

import com.tiankun.eurekasellinfo.mapper.ShopMapper;
import com.tiankun.eurekasellinfo.pojo.Shop;
import com.tiankun.eurekasellinfo.service.ShopService;
import com.tiankun.eurekasellinfo.util.JsonResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;

/**
 * @Author 杨天可
 * @Date 2020/11/14 11:05
 * @Version 1.0
 */
@Service("shopService")
public class ShopServiceImpl implements ShopService {

    @Resource
    ShopMapper shopMapper;

    @Override
    public Map registShop(Shop shop) {

        JsonResult jsonResult = new JsonResult();
        shop.setShopCreated(new Date());
        shop.setShopSell(0);
        shop.setShopState(0);
        shopMapper.registShop(shop);
        jsonResult.setCode("200");
        jsonResult.setMsg("申请成功");
        return jsonResult.getValues();
    }

    @Override
    public Map changeShopState(Integer shopId, Integer State) {
        JsonResult jsonResult = new JsonResult();
        shopMapper.changeShopState(shopId, State);
        jsonResult.setCode("200");
        jsonResult.setMsg("修改成功");
        return  jsonResult.getValues();
    }

    @Override
    public Map selectById(Integer id) {
        JsonResult jsonResult = new JsonResult();

        Shop shop = shopMapper.selectById(id);
        jsonResult.setCode("200");
        jsonResult.setData(shop);
        return jsonResult.getValues();
    }
}
